import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;

import AtmSystem.*;

public class AdminDelectUser extends HttpServlet
{
	public void doPost(HttpServletRequest request, HttpServletResponse response)
		throws ServletException, IOException
                {
                        String AccountName = request.getParameter("cardnumber");

                        ClientDBIO IO = new ClientDBIO();

                        ServletContext sc;
					  sc = getServletContext();
                        String scr =sc.getRealPath("/") +"MyClientDB.dat";
                        ClientDB client = IO.loadClientDB(scr);

                        BankAccountDBIO IO1 = new BankAccountDBIO();     
                        String scr1 =sc.getRealPath("/") +"MyBankAccountDB.dat";

                        BankAccountDB DB = IO1.loadBankAccountDB(scr1);

		

                        if(client.remove(AccountName))
                        {				
						for (int index = 0;index<DB.getNumbers();index ++)
							{
							DB.remove(client.isExsit(AccountName).getBankAccountDB().get(index));
							}
							
                             IO.writerClientDB(scr,client);
							 IO1.writerBankAccountDB(scr1,DB);
                        

                             response.sendRedirect("/AtmSystem/34.html");
		        }
                        else
                        {
                             response.sendRedirect("/AtmSystem/33.html");
                        }
                }
}